package date;

import java.time.Duration;
import java.time.LocalDateTime;

/**
 * Duration：计算日期时间差
 * @author lyy
 * @date 2021/12/20
 */
public class DurationTest {
    public static void main(String[] args) {
        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);
        LocalDateTime next = now.plusDays(5).plusHours(1);
        System.out.println(next);
        Duration duration = Duration.between(now, next);
        System.out.println("相差天数：" + duration.toDays());
        System.out.println("相差小时：" + duration.toHours());
        System.out.println("相差分钟：" + duration.toMinutes());
        System.out.println("相差秒：" + duration.getSeconds());
    }
}
